import pluginJs from '@eslint/js';
import pluginPrettierRecommendedConfigs from 'eslint-plugin-prettier/recommended';
import pluginVue from 'eslint-plugin-vue';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import parserVue from 'vue-eslint-parser';

export default [
	{
		// 必须将忽略文件放到最上面
		ignores: ['dist/*', 'node_modules/*', 'commitlint.config.cjs', 'postcss.config.cjs', '.husky/*', '.stylelintrc.js'],
	},
	// eslint 默认推荐规则
	pluginJs.configs.recommended,
	// ts 默认推荐规则
	...tseslint.configs.recommended,
	// vue3 基础推荐规则
	...pluginVue.configs['flat/recommended'],
	// prettier 默认推荐规则
	pluginPrettierRecommendedConfigs,
	{
		languageOptions: {
			globals: {
				...globals.browser,
				...globals.es2020,
				...globals.node,
			},
			ecmaVersion: 2020,
			parser: parserVue,
			parserOptions: {
				parser: tseslint.parser,
			},
		},
		rules: {
			// 关闭组件必须驼峰命名规则
			'vue/multi-word-component-names': 'off',
			// 允许使用namespace语法
			'@typescript-eslint/no-namespace': 'off',
		},
	},
];
